package week09;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collector;
import java.util.stream.Collectors;

public class Student {
	private Long id; 
	private String name; 
	private int age;
	private Gender gender;
	private boolean joinsACM;
	
	private List<Student> arrayList=new ArrayList<>();
	
	private enum Gender{
		Man,Woman
	}
	
	public Student() {
		super();
	}
	
	public Student(Long id, String name, int age, Gender gender, boolean joinsACM) {
		this.id = id;
		this.name = name;
		this.age = age;
		this.gender = gender;
		this.joinsACM = joinsACM;
	}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public Gender getGender() {
		return gender;
	}

	public void setGender(Gender gender) {
		this.gender = gender;
	}

	public boolean isJoinsACM() {
		return joinsACM;
	}

	public void setJoinsACM(boolean joinsACM) {
		this.joinsACM = joinsACM;
	}
	
	public List<Student> getArrayList() {
		return arrayList;
	}

	public void setArrayList(List<Student> arrayList) {
		this.arrayList = arrayList;
	}

	/*public List<Student> search(Long id, String name, int age, Gender gender, boolean joinsACM) {
		List<Student> students=new ArrayList<Student>();
		for(int i=0;i<arrayList.size();i++) {
			Student student=arrayList.get(i);
			if(student.getId()>id && student.getName().equals(name) 
					&& student.getAge()>age && student.getGender()==gender && student.isJoinsACM()==joinsACM) {
				students.add(student);
			}
		}
		return students;	
	}*/

	public String toString() {
		return "Student:id=" + id + ", name=" + name + ", age=" + age + ", gender=" + gender + ", joinsACM=" + joinsACM;
	}

	public static void main(String[] args) {
		List<Student> list=new ArrayList<>();
		list.add(new Student(201621123067L,"Jintianting",20,Gender.Woman,true));
		list.add(new Student(19970203L,"Jtt",21,Gender.Man,true));
		list.add(new Student(201621123068L,"Jintianing",13,Gender.Man,true));
		list.add(null);
		list.add(new Student(201621123090L,"Jintianting",15,Gender.Woman,true));
		list.add(new Student(201621123123L,"Jintianting",24,Gender.Woman,true));
		list.add(null);
		list.add(new Student(201621123199L,"Jintianting",14,Gender.Man,true));
		list.add(null);
		list.add(null);
	    try {
		list.stream().filter(e-> e.getId()>201621123065L 
				&& e.getName().equals("Jintianting")
				&&  e.getAge()>3 && e.getGender()==Gender.Woman 
				&& e.isJoinsACM()==true ).forEach(System.out::println);
		}catch(NullPointerException e) {
		
		}
		/*list.stream().filter(e->e!=null && e.getId()>201621123065L 
					&& e.getName().equals("Jintianting")
					&&  e.getAge()>3 && e.getGender()==Gender.Woman 
					&& e.isJoinsACM()==true )
			.collect(Collectors.toList()).forEach(System.out::println);
			*/
	   
	   
	}


}
